home *** CD-ROM | disk | FTP | other *** search
/ The Games Machine 103 / XENIATGM103.iso / Shareware / GoLive 5.0 / MM9.Cab / F1489_office.runtime5.asp.9B3B646D_CB56_4EAE_BAB7_3E7E8E41A649 < prev    next >
Text File  |  2000-08-17  |  3KB  |  132 lines

  1. <SCRIPT runat="server" language="VBScript">
  2.     
  3. ' *****************************************************************************
  4. '
  5. ' include/office.runtime5.asp
  6. '
  7. ' Dynamic Link runtime support for Microsoft Office.
  8. '
  9. ' COPYRIGHT (c) 1999-2000 Adobe Systems Incorporated. All rights reserved.
  10. '
  11. </SCRIPT>
  12.  
  13.  
  14.  
  15. <SCRIPT runat="server" language="JScript">
  16.     
  17. // *****************************************************************************
  18. // CONTENT SOURCE WRAPPER: WORD
  19. //
  20. // Content source wrapper for representing a Word document as a single record
  21. // containing a field for each distinct paragraph style.  The field values are
  22. // the concatenation of all paragraphs of that style.
  23. //
  24. // Items are accessed through the wrapper as follows:
  25. //
  26. //      set word = Server.CreateObject("Word.Application")
  27. //      set document = word.Documents.Open(Server.MapPath("word.doc"))
  28. //      set results = WrapWordDoc(document)
  29. //      results.Value("Heading1")
  30.  
  31. function WrapWordDoc(wordDoc)
  32. {
  33.     return new CSWWordDoc(wordDoc);
  34. }
  35.  
  36. function CSWWordDoc(wordDoc)
  37. {
  38.     // Method table:
  39.     this.Move = CSW_NOP;
  40.     this.MoveFirst = CSW_NOP;
  41.     this.MoveNext = CSW_NOP;
  42.     this.Value = CSWWordDoc_Value;
  43.     this.Set = CSW_NOP;
  44.     this.UpdateBatch = CSW_NOP;
  45.  
  46.     this.Data = new Object;
  47.     for (var i = 1; i <= wordDoc.Paragraphs.Count; i++) {
  48.         var p = wordDoc.Paragraphs.Item(i);
  49.         if (typeof(this.Data[p.Style]) == "undefined") {
  50.             this.Data[p.Style] = p.Range;
  51.         } else {
  52.             this.Data[p.Style] += p.Range;
  53.         }
  54.     }
  55.  
  56.     this.RecordCount = 1;
  57.     this.AbsolutePosition = 1;
  58.     this.EOF = true;
  59. }
  60.  
  61. // -----------------------------------------------------------------------------
  62. // Methods:
  63.  
  64. function CSWWordDoc_Value(fieldName)
  65. {
  66.     return this.Data[fieldName];
  67. }
  68.  
  69.  
  70. // *****************************************************************************
  71. // CONTENT SOURCE WRAPPER: EXCEL
  72. //
  73. // Content source wrapper for representing an Excel worksheet as a record set
  74. // containing a record for each row comprising a field for each column.     The
  75. // first row is assumed to contain the column names.
  76. //
  77. // Items are accessed through the wrapper as follows:
  78. //
  79. //      set xl = Server.CreateObject("Excel.Application")
  80. //      set workbook = xl.Workbooks.Open(Server.MapPath("sheet.xls"))
  81. //      set sheet = workbook.Worksheets(1)
  82. //      set results = WrapExcelSheet(sheet)
  83. //      results.MoveFirst
  84. //      results.Value("MSRP")
  85.  
  86. function WrapExcelSheet(xlSheet)
  87. {
  88.     return new CSWExcelSheet(xlSheet);
  89. }
  90.  
  91. function CSWExcelSheet(xlSheet)
  92. {
  93.     // Method table:
  94.     this.Move = CSW_Move;
  95.     this.MoveFirst = CSW_MoveFirst;
  96.     this.MoveNext = CSW_MoveNext;
  97.     this.Value = CSWExcelSheet_Value;
  98.     this.Set = CSW_NOP;
  99.     this.UpdateBatch = CSW_NOP;
  100.  
  101.     this.Data = xlSheet;
  102.  
  103.     this.FieldMap = new Object;
  104.     var i = 1;
  105.     while (typeof(xlSheet.Cells(1, i).Value) != "undefined") {
  106.         this.FieldMap[xlSheet.Cells(1, i).Value] = i;
  107.         i++;
  108.     }
  109.  
  110.     this.RecordCount = 0;
  111.     while (typeof(xlSheet.Cells(this.RecordCount+2, 1).Value) != "undefined") {
  112.         this.RecordCount++;
  113.     }
  114.  
  115.     this.MoveFirst();
  116. }
  117.  
  118. // -----------------------------------------------------------------------------
  119. // Methods:
  120.  
  121. function CSWExcelSheet_Value(fieldName)
  122. {
  123.     var rowIndex = this.AbsolutePosition + 1; // add 1 for column names
  124.     var colIndex = this.FieldMap[fieldName];
  125.  
  126.     return this.Data.Cells(rowIndex, colIndex).Value;
  127. }
  128.  
  129.  
  130. </SCRIPT>
  131.  
  132.